package com.mango.leet.code.week2.game379;

/**
 * https://leetcode.cn/contest/weekly-contest-379/problems/minimum-moves-to-capture-the-queen/
 * @Author: mango
 * @Date: 2024/1/7 11:00
 */
public class LC100187 {
    public static int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
        // 先判断直接命中
        boolean directTarget = false;
        // 可以对角线
        boolean canDjx = c+e == d+f;
        // 对角线有遮挡(同一边，且内部）
        boolean sameWay = false;
        if ((a < e && c < e && c > a) || (a > e && c > e && c < a)) {
            sameWay = true;
        }
        boolean onWay = a+e == b+f && sameWay;
        // 可以直线
        boolean canDirect = a == e || b == f;
        // 直线有遮挡
        boolean directWay = false;
        if (((a == c && a == e) && (b > f && d > f && b > d))
            || ((a == c && a == e) && (b < f && d < f && b < d))
            || ((b == f && d == f) && (a < e && c < e && a < c))
            || ((b == f && d == f) && (a > e && c > e && a > c))
        ) {
            directWay = true;
        }
        if ((canDirect && !directWay) || (canDjx && !onWay)) {
            directTarget = true;
        }
        // 不能直接命中，则返回2
        return directTarget ? 1 : 2;
    }
    public static void main(String[] args) {
        //int a = 4, b = 3, c = 3, d = 4, e = 5, f = 2;
        //int a = 1, b = 1, c = 8, d = 8, e = 2, f = 3;
        //int a = 5, b = 3, c = 3, d = 4, e = 5, f = 2;
        int a = 1, b = 1, c = 1, d = 4, e = 1, f = 8;
        System.out.println(minMovesToCaptureTheQueen(a, b, c, d, e, f));
    }
}
